# -*- coding: utf-8 -*-

from genpy.HelloThrift.Interface import HelloService
from genpy.HelloThrift.Interface.ttypes import *
from genpy.HelloThrift.Interface.constants import *

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

try:
  transport = TSocket.TSocket('127.0.0.1', 8086)
  transport = TTransport.TBufferedTransport(transport)
  protocol = TBinaryProtocol.TBinaryProtocol(transport)
  client = HelloService.Client(protocol)
  transport.open()
  hs = client.HelloString("Python ThriftClient")
  print (hs)
  transport.close()
except Thrift.TException, tx:
  print "%s" % (tx.message)

